package org.jeecg.modules.kafka;

import lombok.extern.slf4j.Slf4j;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;


@Component
@Slf4j
public class KafkaProducer {

    @Resource
    private KafkaTemplate<String, String> kafkaTemplate;

    /**
     * 发送json消息
     *
     * @param topic 频道
     * @param message  消息
     */
    public void send(String topic, String message) {
        kafkaTemplate.send(topic, message);
        log.info("消费发送成功，topic为：{}，内容为：{}", topic, message);
    }


}
